package com.cskaoyan.wxcontroller;

import com.cskaoyan.bean.baseresultVO.BaseRespVo;
import com.cskaoyan.bean.wxsearch.IndexVo;
import com.cskaoyan.service.WxSearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author lirui
 * @Date 2021/12/2 11:19
 * @describe:
 */
@RestController
@RequestMapping("wx/search")
public class WxSearchController {
    @Autowired
    WxSearchService wxsearchService;

    @RequestMapping("index")
    public BaseRespVo doIndex(){
        IndexVo data=wxsearchService.getIndex();
        return BaseRespVo.ok(data);
    }

    @RequestMapping("helper")
    public BaseRespVo searchHelper(@RequestParam("keyword") String keyword){
        /**
         * 该种请求不添加历史记录，不做操作，直接响应成功即可
         */

        ArrayList<String> data= wxsearchService.getGoodsList(keyword);
        return BaseRespVo.ok(data);
    }
    @RequestMapping("clearhistory")
    public BaseRespVo doClearHistory(){
       
        wxsearchService.deleteHistory();
        return BaseRespVo.ok();
    }

}
